package com.tcm.portal.web.controller;

import com.base.core.utils.R;
import com.tcm.store.service.StoreService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.*;

@RequestMapping("/portal")
@RestController
public class StoreController {

    @DubboReference(version = "0.0.1-alpha", check = false, timeout = 3000)
    private StoreService storeService;

    @GetMapping("/store/view")
    public R view(@RequestParam("id") Long id) throws Exception {
        return R.success(storeService.findStoreById(id));
    }

    /**
     * 基本运费
     * @return
     * @throws Exception
     */
    @GetMapping("/store/logisticsfee")
    public R logisticsFee(@RequestParam("provinceId") Long provinceId, @RequestParam("storeId")Long storeId) {
        String fee;
        try {
            fee = storeService.logisticsFee(provinceId,storeId);
        } catch (Exception e) {
            return R.fail(e.getMessage());
        }
        return R.success(fee);
    }


}
